 CREATE PROCEDURE [dbo].[ProviderClinicTypeSave]
	@Id				UNIQUEIDENTIFIER,
	@ProviderId		UNIQUEIDENTIFIER,
	@ClinicTypeId	UNIQUEIDENTIFIER,
	@SlotsAvailable INT,
	@SlotDuration	INT,
	@DayStartTime	DATETIME,
	@DayEndTime		DATETIME,
	@WeekDays		INT
AS

DECLARE	@RowCount AS INT
DECLARE @Error AS INT

UPDATE	ProviderClinicType
SET		ProviderId			= ISNULL(@ProviderId,ProviderId),
		ClinicTypeId		= ISNULL(@ClinicTypeId, ClinicTypeId),
		SlotsAvailable		= ISNULL(@SlotsAvailable, SlotsAvailable),
		SlotDuration		= ISNULL(@SlotDuration, SlotDuration),
		DayStartTime		= ISNULL(@DayStartTime, DayStartTime),
		DayEndTime			= ISNULL(@DayEndTime, DayEndTime),
		WeekDays			= ISNULL(@WeekDays, WeekDays)
WHERE	Id = @Id

SELECT @Error = @@ERROR, @RowCount = @@ROWCOUNT

IF @Error  <> 0
BEGIN
	RAISERROR('ERROR::ProviderClinicTypeSave:Error in',16,1)
END

IF @RowCount  > 0
BEGIN
	RETURN @RowCount 
END

--	If adding for first time enter all the details including UBRN
INSERT	INTO ProviderClinicType (Id, ProviderId, ClinicTypeId, SlotsAvailable, SlotDuration, DayStartTime, DayEndTime, WeekDays)		
VALUES	(@Id, @ProviderId, @ClinicTypeId, @SlotsAvailable, @SlotDuration, @DayStartTime, @DayEndTime, @WeekDays)		

SELECT	@Error = @@ERROR, @RowCount = @@ROWCOUNT

IF @Error  <> 0
BEGIN
	RAISERROR('ERROR::ProviderClinicTypeNew:Error in',16,1)
END

RETURN @RowCount